#include "ParserClear.h"

const string ParserClear::clearKeyword = "clear";

ParserClear::ParserClear(ParserBase *_nextParser) : ParserBase (_nextParser) {
}

bool ParserClear::tryParse(string userCommand, CommandBase*& parsedCommand) {
	// stringstream to extract instruction
	stringstream wordExtractor(userCommand);
	string command;

	wordExtractor >> command;
	wordExtractor >> ws;

	bool isSuccess = (!wordExtractor.fail() &&
					  wordExtractor.eof() &&
					  // ensure that string compare is not case sensitive
					  boost::iequals(command, clearKeyword));

	if (isSuccess) {
		parsedCommand = new CommandClear();
	}else {
		parsedCommand = new CommandClear();
	}

	return isSuccess;
}